<template>
  <div>
    <input type="text"
           v-model.lazy="user"
           placeholder="username">
    <input type="password"
           v-model.lazy="password"
           placeholder="passowrd">
    <button @click='handleLogin'>登录</button>

  </div>
</template>
<script>
export default {
  data () {
    return {
      user: '',
      password: ''
    }
  },
  // 判断本地存储有没有存储user的键值
  methods: {
    handleLogin () {
      setTimeout(() => {
        localStorage.setItem('user', this.password)
        // console.log(this.$route.query)
        if (this.$route.query.redirect) {
          this.$router.push(this.$route.query.redirect)
        } else {
          this.$router.push('/films')
        }

      }, 1);

    }
  },
}
</script>